package
{
	import generated.webservices.ArrayOfTagTreeInfo;
	import generated.webservices.TagTreeInfo;
	
	import mx.collections.ICollectionView;
	import mx.controls.treeClasses.ITreeDataDescriptor;

	public final class TagTreeDataDescriptor implements ITreeDataDescriptor
	{
		public function getChildren(node:Object, model:Object=null):ICollectionView
		{
			return (node as TagTreeInfo).Children;
		}
		
		public function hasChildren(node:Object, model:Object=null):Boolean
		{
			if (node is TagTreeInfo)
			{
				var cs: ArrayOfTagTreeInfo = (node as TagTreeInfo).Children;
				return cs != null && cs.length > 0;
			}
			else
				return true;
		}
		
		public function isBranch(node:Object, model:Object=null):Boolean
		{
			return hasChildren(node);
		}
		
		public function getData(node:Object, model:Object=null):Object
		{
			return node;
		}
		
		public function addChildAt(parent:Object, newChild:Object, index:int, model:Object=null):Boolean
		{
			throw new Error("Operation is not supported");
		}
		
		public function removeChildAt(parent:Object, child:Object, index:int, model:Object=null):Boolean
		{
			throw new Error("Operation is not supported");
		}
		
	}
}